const http = require("http");
const fs = require("fs");
http.createServer((req, res) => {

    res.writeHead(200, {
        "content-type": "text/html;charset=utf-8"
    });
    //路由
    console.log(req.url);
    if (req.url == "/index" || req.url == "/") {
        fs.readFile("index.html", (err, con) => {
            if (err) return;
            res.end(con.toString());
        })
    } else if (req.url == "/login") {
        fs.readFile("login.html", (err, con) => {
            if (err) return;
            res.end(con.toString());
        })
    } else if (req.url == "/regist") {
        fs.readFile("regist.html", (err, con) => {
            if (err) return;
            res.end(con.toString());
        })
    } else {
        fs.readFile("404.html", (err, con) => {
            if (err) return;
            res.end(con.toString());
        })
    }
}).listen(3000, "127.0.0.1");
